<?php
/**********************************************
* 파일명: ttskinget.php
* 설  명: 텍스트큐브 공개스킨을 다운로드하는 파일입니다.
***********************************************/
require "lib.php";

$skinname = $_GET['skinname'];
$skinname = urldecode($skinname);
$skindown = $_GET['skindown'];
$skindown = urldecode($skindown);
$ttSkinDownURL =  TT_SkinManagerServerURL()."skinfiles/";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title><?php echo pluginLang::plts('스킨매니저 :: 다운로드');?></title>
	<link rel="stylesheet" type="text/css" media="screen" href="<?php echo $service['path'];?>/style/admin/default/plugin-config.css" />
	<style type="text/css">
		body
		{
			font-size: 75%;
		}
		
		.text1
		{
			background-color: #efefef;
			margin-bottom: 10px;
			padding: 10px;
		}
		
		.message
		{
			text-align: center;
		}
		
		.messages
		{
			list-style-type: none;
			padding: 10px 20px;
		}
		
		.messages li
		{
			color: #999;
			list-style-type: none;
		}
		
		.messages li.depth1 span
		{
			visibility: hidden;
		}
		
		#layout-foot
		{
			position: absolute;
			bottom: 0;
			padding-left: 0;
			padding-right: 0;
			width: 100%;
		}
	</style>
	<script language="JavaScript" type="text/javascript">
		//<![CDATA[
			function js_close(){
				location.reload();
				opener.location.reload();
				//self.close();
			}
		//]]>
	</script>
</head>
<body>
	<div>
		<div id="layout-head">
			<h1 class="caption"><?php echo pluginLang::plts('스킨매니저 :: 다운로드');?></h1>
		</div>
		
		<div id="layout-body">
			<p class="text1 headtext1"><?php echo pluginLang::plts('스킨이름');?> : <strong><?php echo $skinname;?></strong></p>
			
			<ul class="messages">
<?php
$skinfolder = $start.$skinname;

list($skinfolders, $skinfiles) = TT_SkinManagerGetSkinInfo($skindown);

foreach($skinfolders as $folder){

	$makefolder = $start.$folder;
	if(!is_dir($makefolder)) {
		mkdir($makefolder);
		@chmod($makefolder,0777);
	}
	if(!is_writable($makefolder)){
		die(pluginLang::plts('파일저장 권한이 없습니다'));
	}
	echo "<li> - ". $folder.pluginLang::plts('폴더를 생성하였습니다')."</li>";

	if(isset($skinfiles[$folder])){
	$files = $skinfiles[$folder];
		foreach($files as $file){
			$getfileurl = $ttSkinDownURL.$folder."/".$file;
			TT_SkinManagerSaveSkinfiles($makefolder, $file, $getfileurl);
		}
		echo '<li class="depth1"><span> - </span>'.$folder.pluginLang::plts('폴더의 스킨파일이 저장되었습니다.').'</li>';
	}
	flush();
}
?>
			</ul>
			
			<p class="message"><em><strong><?php echo $skinname;?></strong> <?php echo pluginLang::plts('스킨 다운로드 완료. 내 스킨폴더에서 확인하세요.');?></em></p>
		</div>
		
		<div id="layout-foot">
			<input type="button" class="input-button" value="<?php echo pluginLang::plts('닫기');?>" onclick="self.close();return false;" />
		</div>
	</div>
</body>
</html>
